﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Pages_ManagerPages_updateStudent : System.Web.UI.Page
{
    int id=0;
    protected void Page_Load(object sender, EventArgs e)
    {
        id =Convert.ToInt32(Request.QueryString["id"].ToString());
        ManagerBUS m = new ManagerBUS();
        DataSet ds = m.searchStudentById(id);
        txtFullName.Text = ds.Tables[0].Rows[0]["fullName"].ToString();
        txtUserName.Text = ds.Tables[0].Rows[0]["userName"].ToString();
        txtAddress.Text = ds.Tables[0].Rows[0]["address"].ToString();
        txtClass.Text = ds.Tables[0].Rows[0]["class"].ToString();
        txtEmail.Text = ds.Tables[0].Rows[0]["email"].ToString();
        txtPhone.Text = ds.Tables[0].Rows[0]["phoneNo"].ToString();
        txtMajor.Text = ds.Tables[0].Rows[0]["major"].ToString();
    }
    protected void btnUpdateStudent_Click(object sender, EventArgs e)
    {
        ManagerBUS m = new ManagerBUS();
        Student st = new Student();
        st.Id = id;
        st.Address = txtAddress.Text;
        st.Email = txtEmail.Text;
        st.Fullname = txtFullName.Text;
        st.Major = txtMajor.Text;
        st.PhoneNumber = txtPhone.Text;
        st.Username = txtUserName.Text;
        st._class1 = txtClass.Text;
        if (m.updateStudent(st))
        {
            Response.Redirect("~/Pages/HomePage/Success.aspx");
        }
        else
        {
            lblWarningUpdateStudent.Text = "Failed";
        }
    }
}